using UnityEngine;
using System.Collections;

/// \class  gkCylindricalInnerOrientationConstraint
/// \brief 	Cylindrical inner orientation constraint
[AddComponentMenu("GK/Engine/Core/Transform/gkCylindricalInnerOrientationConstraint")]
[RequireComponent(typeof(gkCylindricalPosition))]
public class gkCylindricalInnerOrientationConstraint : MonoBehaviour
{
	/// The cylindrical position
	private gkCylindricalPosition m_rCylindricalPosition;
	
	/// \brief  Called just before the first update
	void Start() 
	{
		// Get the cylindrical position component
		m_rCylindricalPosition = GetComponent<gkCylindricalPosition>();
	
		// Initialize the orientation
		ConstraintOrientationToAimTheCynliderInterior();
	}

	/// \brief  Event called each frame
    void Update()
    {
		// Update the orientation
		ConstraintOrientationToAimTheCynliderInterior();
	}
	
	/// \brief  Constraint Orientation To Aim The Cynlider Interior
	void ConstraintOrientationToAimTheCynliderInterior()
	{
		Vector3 f3EulerAngles = Vector3.zero;
		
		f3EulerAngles.z = m_rCylindricalPosition.position.y;
		
		transform.eulerAngles = f3EulerAngles;
	}
}